package com.richard.room.app;

import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;

import com.richard.room.app.entity.Book;
import com.richard.room.app.entity.Device;
import com.richard.room.app.entity.User;
import com.richard.room.operator.api.dao.Dao;

import java.util.List;

/**
 * @author: Richard
 * @createDate: 2023/8/8 14:26
 * @version: 1.0
 * @description: 描述
 */
@androidx.room.Dao
public abstract class TestDao extends Dao<User> {

    @Insert
    public abstract List<Long> insertBook(List<Book> data);

    @Insert
    public abstract void insertBook2(List<Book> data);

    @Insert
    public abstract void insertBook3(Book data);

    @Insert
    public abstract List<Long> insertDevice(List<Device> data);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    public abstract List<Long> saveBook(List<Book> data);

    @Query("delete from tb_user  where id = :id")
    public abstract int deleteById(long id);

    @Query("delete from tb_user  where id = :id")
    public abstract void deleteById2(long id);

    @Query("update tb_user set user_name = 'a-b'  where id = :id")
    public abstract int updateById(long id);

    @Query("select * from tb_user where id = :id")
    public abstract List<User> findById(long id);

    @Query("select * from tb_user where user_name = :name")
    public abstract List<User> findByName(String name);
}
